package com.deyuanyun.pic.ae.controller.dto;

import com.deyuanyun.pic.ae.domain.AEPipeline;
import com.deyuanyun.pic.ae.domain.Sewer;
import com.deyuanyun.pic.ae.domain.SpecificPlace;
import com.deyuanyun.pic.common.util.DateUtil;
import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import org.springframework.validation.Errors;

import java.math.BigDecimal;
import java.util.Date;

/**
 * E_4管道沿线地下排水排污设施信息表
 */
public class SewerEdit extends AEBaseEdit<Sewer> {

    // 管道编号
    private String pipeLineId;
    // 设施名称
    private String name;
    // 类型AESEWER_TYPE（公路、铁路、高铁、地铁、高架、其它）
    private String type;
    // 所属单位
    private String owner;
    // 联系方式
    private String telephone;
    // 相对位置关系（交叉、平行）CROSS、PARALLEL
    private String relativePositionRelation;

    // (填写)交叉段_附近测试桩pic_pipe_identification.ID_
    private String crossNagmInput;
    // (填写)交叉段_附近测试桩距离（相对值）
    private BigDecimal crossNagmMileageInput;
    // 交叉X
    private BigDecimal crossX;
    // 交叉Y
    private BigDecimal crossY;
    // 交叉Z
    private BigDecimal crossZ;

    // (填写)平行起点_附近测试桩pic_pipe_identification.ID_
    private String beginNagmInput;
    // (填写)平行起点_附近测试桩距离（相对值）
    private BigDecimal beginNagmMileageInput;
    // 起点X
    private BigDecimal beginX;
    // 起点Y
    private BigDecimal beginY;
    // 起点Z
    private BigDecimal beginZ;
    // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
    private String endNagmInput;
    // (填写)平行段终点_附近测试桩距离（相对值）
    private BigDecimal endNagmMileageInput;
    // 终点X
    private BigDecimal endX;
    // 终点Y
    private BigDecimal endY;
    // 终点Z
    private BigDecimal endZ;
    // 位置描述
    private String locationDescription;
    // 最小平行间距（m）
    private BigDecimal minDistance;
    // 是否密闭空间（TES、NO）
    private String confinedSpace;

    public String getPipeLineId() {
        return pipeLineId;
    }

    public void setPipeLineId(String pipeLineId) {
        this.pipeLineId = pipeLineId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getRelativePositionRelation() {
        return relativePositionRelation;
    }

    public void setRelativePositionRelation(String relativePositionRelation) {
        this.relativePositionRelation = relativePositionRelation;
    }

    public String getCrossNagmInput() {
        return crossNagmInput;
    }

    public void setCrossNagmInput(String crossNagmInput) {
        this.crossNagmInput = crossNagmInput;
    }

    public BigDecimal getCrossNagmMileageInput() {
        return crossNagmMileageInput;
    }

    public void setCrossNagmMileageInput(BigDecimal crossNagmMileageInput) {
        this.crossNagmMileageInput = crossNagmMileageInput;
    }

    public BigDecimal getCrossX() {
        return crossX;
    }

    public void setCrossX(BigDecimal crossX) {
        this.crossX = crossX;
    }

    public BigDecimal getCrossY() {
        return crossY;
    }

    public void setCrossY(BigDecimal crossY) {
        this.crossY = crossY;
    }

    public BigDecimal getCrossZ() {
        return crossZ;
    }

    public void setCrossZ(BigDecimal crossZ) {
        this.crossZ = crossZ;
    }

    public String getBeginNagmInput() {
        return beginNagmInput;
    }

    public void setBeginNagmInput(String beginNagmInput) {
        this.beginNagmInput = beginNagmInput;
    }

    public BigDecimal getBeginNagmMileageInput() {
        return beginNagmMileageInput;
    }

    public void setBeginNagmMileageInput(BigDecimal beginNagmMileageInput) {
        this.beginNagmMileageInput = beginNagmMileageInput;
    }

    public BigDecimal getBeginX() {
        return beginX;
    }

    public void setBeginX(BigDecimal beginX) {
        this.beginX = beginX;
    }

    public BigDecimal getBeginY() {
        return beginY;
    }

    public void setBeginY(BigDecimal beginY) {
        this.beginY = beginY;
    }

    public BigDecimal getBeginZ() {
        return beginZ;
    }

    public void setBeginZ(BigDecimal beginZ) {
        this.beginZ = beginZ;
    }

    public String getEndNagmInput() {
        return endNagmInput;
    }

    public void setEndNagmInput(String endNagmInput) {
        this.endNagmInput = endNagmInput;
    }

    public BigDecimal getEndNagmMileageInput() {
        return endNagmMileageInput;
    }

    public void setEndNagmMileageInput(BigDecimal endNagmMileageInput) {
        this.endNagmMileageInput = endNagmMileageInput;
    }

    public BigDecimal getEndX() {
        return endX;
    }

    public void setEndX(BigDecimal endX) {
        this.endX = endX;
    }

    public BigDecimal getEndY() {
        return endY;
    }

    public void setEndY(BigDecimal endY) {
        this.endY = endY;
    }

    public BigDecimal getEndZ() {
        return endZ;
    }

    public void setEndZ(BigDecimal endZ) {
        this.endZ = endZ;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public BigDecimal getMinDistance() {
        return minDistance;
    }

    public void setMinDistance(BigDecimal minDistance) {
        this.minDistance = minDistance;
    }

    public String getConfinedSpace() {
        return confinedSpace;
    }

    public void setConfinedSpace(String confinedSpace) {
        this.confinedSpace = confinedSpace;
    }

    @Override
    public void fromDomain(Sewer domain){

        // 管道编号
        this.pipeLineId = domain.getPipeLineId();
        // 设施名称
        this.name = domain.getName();
        // 类型AESEWER_TYPE（公路、铁路、高铁、地铁、高架、其它）
        this.type = domain.getType();
        // 所属单位
        this.owner = domain.getOwner();
        // 联系方式
        this.telephone = domain.getTelephone();
        // 相对位置关系（交叉、平行）CROSS、PARALLEL
        this.relativePositionRelation = domain.getRelativePositionRelation();
        // (填写)交叉段_附近测试桩pic_pipe_identification.ID_
        this.crossNagmInput = StringUtils.isNotNullEmpty(domain.getCrossNagmNumberInput()) ? domain.getCrossNagmNumberInput() : domain.getCrossNagmNumber();
        // (填写)交叉段_附近测试桩距离（相对值）
        this.crossNagmMileageInput = NumberUtil.toMeter(StringUtils.isNotNullEmpty(domain.getCrossNagmNumberInput()) ? domain.getCrossNagmMileageInput() : domain.getCrossNagmMileage());
        // 交叉_x
        this.crossX = domain.getCrossX();
        // 交叉_y
        this.crossY = domain.getCrossY();
        // 交叉_z
        this.crossZ = domain.getCrossZ();
        // (填写)平行起点_附近测试桩pic_pipe_identification.ID_
        this.beginNagmInput = StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ? domain.getBeginNagmNumberInput() : domain.getBeginNagmNumber();
        // (填写)平行起点_附近测试桩距离（相对值）
        this.beginNagmMileageInput = NumberUtil.toMeter(StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ? domain.getBeginNagmMileageInput() : domain.getBeginNagmMileage());
        // 平行_起点x
        this.beginX = domain.getBeginX();
        // 平行_起点y
        this.beginY = domain.getBeginY();
        // 平行_起点z
        this.beginZ = domain.getBeginZ();
        // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
        this.endNagmInput = StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmNumberInput() : domain.getEndNagmNumber();
        // (填写)平行段终点_附近测试桩距离（相对值）
        this.endNagmMileageInput = NumberUtil.toMeter(StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmMileageInput() : domain.getEndNagmMileage());
        // 平行_终点x
        this.endX = domain.getEndX();
        // 平行_终点y
        this.endY = domain.getEndY();
        // 平行_终点z
        this.endZ = domain.getEndZ();
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 最小平行间距（m）
        this.minDistance = domain.getMinDistance();
        // 是否密闭空间（TES、NO）
        this.confinedSpace = domain.getConfinedSpace();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    @Override
    public Sewer toDomain() {

        Sewer sewer = new Sewer();
        // 管道编号
        sewer.setPipeLineId(this.pipeLineId);
        // 设施名称
        sewer.setName(this.name);
        // 类型AESEWER_TYPE（公路、铁路、高铁、地铁、高架、其它）
        sewer.setType(this.type);
        // 所属单位
        sewer.setOwner(this.owner);
        // 联系方式
        sewer.setTelephone(this.telephone);
        // 相对位置关系（交叉、平行）CROSS、PARALLEL
        sewer.setRelativePositionRelation(relativePositionRelation);
        // (填写)交叉段_附近测试桩pic_pipe_identification.ID_
        sewer.setCrossNagmInput(this.crossNagmInput);
        // (填写)交叉段_附近测试桩距离（相对值）
        sewer.setCrossNagmMileageInput(NumberUtil.toMillimeter(this.crossNagmMileageInput));
        // 交叉_x
        sewer.setCrossX(this.crossX);
        // 交叉_y
        sewer.setCrossY(this.crossY);
        // 交叉_z
        sewer.setCrossZ(this.crossZ);
        // (填写)平行起点_附近测试桩pic_pipe_identification.ID_
        sewer.setBeginNagmInput(this.beginNagmInput);
        // (填写)平行起点_附近测试桩距离（相对值）
        sewer.setBeginNagmMileageInput(NumberUtil.toMillimeter(this.beginNagmMileageInput));
        // 平行_起点x
        sewer.setBeginX(this.beginX);
        // 平行_起点y
        sewer.setBeginY(this.beginY);
        // 平行_起点z
        sewer.setBeginZ(this.beginZ);
        // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
        sewer.setEndNagmInput(this.endNagmInput);
        // (填写)平行段终点_附近测试桩距离（相对值）
        sewer.setEndNagmMileageInput(NumberUtil.toMillimeter(this.endNagmMileageInput));
        // 平行_终点x
        sewer.setEndX(this.endX);
        // 平行_终点y
        sewer.setEndY(this.endY);
        // 平行_终点z
        sewer.setEndZ(this.endZ);
        // 位置描述
        sewer.setLocationDescription(this.locationDescription);
        // 最小平行间距（m）
        sewer.setMinDistance(this.minDistance);
        // 是否密闭空间（TES、NO）
        sewer.setConfinedSpace(this.confinedSpace);

        // id
        sewer.setId(this.getId());
        // 记录人
        sewer.setRecorder(this.getRecorder());
        // 记录时间
        Date recordTimeTemp = null;
        try {
            recordTimeTemp = DateUtil.allStr2Date(this.getRecordTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
        sewer.setRecordTime(recordTimeTemp);
        // 备注
        sewer.setRemarks(this.getRemarks());

        return sewer;
    }
}